from datetime import datetime
from mock import Mock

def create_mock_entry_results(results):
    m = Mock()
    m.total_results.text = str(len(results))
    m.entry = results

    return m

def create_mock_entry(title='', description='',
        url='http://www.youtube.com/watch?v=CUJ13yzYAXY',
        author='', published_date=datetime.utcnow()):
    """
    Creates a mock object structured like a YouTube video entry.
    """

    mock = Mock()
    mock.title.text = title
    mock.media.description.text = description

    link = Mock()
    link.href = url
    mock.link = [link]

    author_mock = Mock()
    author_mock.name.text = author

    mock.author = [author_mock]
    mock.published.text = published_date.strftime('%Y-%m-%dT%H:%M:%S.000Z')

    return mock
